<template>
  <div id="main" style="width: 600px; height: 400px;"></div>
</template>

<script>
import * as echarts from 'echarts/core';
import { GridComponent } from 'echarts/components';
import { LineChart } from 'echarts/charts';
import { UniversalTransition } from 'echarts/features';
import { CanvasRenderer } from 'echarts/renderers';

echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition]);

export default {
  data() {
    return {
      myChart: null,
      option: {
        xAxis: {
          type: 'category',
          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [150, 230, 224, 218, 135, 147, 0],
            type: 'line'
          }
        ]
      }
    };
  },
  mounted() {
    // 初始化ECharts实例
    this.myChart = echarts.init(document.getElementById('main'));
    // 设置图表选项
    this.myChart.setOption(this.option);
  }
};
</script>
